﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using PowerCreator.LMS.Logic.QuestionManager;
using System.Text;

//using PowerCreator.LMS.Logic.Common;
//using PowerCreator.LMS.Logic.FusionCharts;
//using PowerCreator.LMS.Logic.PaperManager;

public partial class sysadmin_CountManager_AllPaperPass : PowerCreator.LMS.Web.Base.BasePage
{
    #region XML数据模版 ？为什么不采用模版的方式，新建了FusionCharts类，但是不能用

    //图表抬头 Title, xAxisName=X轴的名称，yAxisName=y轴显示的名称,yAxisMaxValue=y轴最大值
    const string GRAPH = "<graph  caption='试卷通过率统计图'  xAxisName='通过率状态' yAxisName='试卷名称列表' decimalPrecision='0' formatNumberScale='0' yAxisMaxValue='100' baseFontSize='14'> ";
    //名称，值，颜色
    const string GRAPH_TR = "<set name='{0}' value='{1}' color='{2}' />";
    const string GRAPH_END = "</graph>";
    //const string REPORT_URL = "/FusionCharts/FCF_Column3D.swf";


    //使用另一个
    const string CHART = "<chart caption='试卷通过统计' xAxisName='试卷名称列表' yAxisName='通过人数' showValues='0' decimals='0' formatNumberScale='0' yAxisMaxValue='100' baseFontSize='14'>";
    const string CHART_TR = "<set name='{0}' value='{1}'/>";
    const string CHART_END = "</chart>";
    #endregion 

    //ManagerPaperInfo paperManager = new ManagerPaperInfo();
    //ManagerUserPaperHistoryInfo userPaperHistoryManager = new ManagerUserPaperHistoryInfo();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //string xml = GetXML();
            //if (string.IsNullOrEmpty(xml))
            //{
            //    Literal1.Text = "目前试卷库中没有数据可进行统计！";
            //}
            //else
            //{
            //    Literal1.Text = InfoSoftGlobal.FusionCharts.RenderChartHTML(FCTemplate.GetColumn3D(), "", xml, "myxml", "800", "400", false);   
            //}
        }        
    }
   
    public DataTable GetAllPaperPass()
    {
        //返回试卷统计信息
        DataTable dt = new DataTable();
        //dt = paperManager.Query("");
        return dt;
    }
    public string GetXML()
    {
        //返回试卷通过率的XML数据
        //StringBuilder sbXml = new StringBuilder();
        //sbXml.Append(string.Format(VIEW_START));
        //DataTable dt = GetAllPaperPass();

        //int passv = 0;
        //int showv = 0;
        //for (int i = 0; i < dt.Rows.Count; i++)
        //{
        //    passv = GetPaperPassCount(int.Parse(dt.Rows[i]["PaperID"].ToString()));
        //    if (passv == 0)
        //        showv += 1;
        //    //名称，值，颜色
        //    sbXml.Append(string.Format(GRAPH_TR, dt.Rows[i]["PaperName"].ToString(), passv, ReportUtils.GetColorRander(6)));
        //}
        //sbXml.Append(GRAPH_END);
        //if (showv == dt.Rows.Count)
        //{
        //    sbXml.Remove(0,sbXml.Length);
        //}
        //return sbXml.ToString();
        StringBuilder sbXML = new StringBuilder();
        //DataTable dt = GetAllPaperPass();
        //if (dt.Rows.Count != 0)
        //{
        //    int passv = 0;
        //    int maxv = 0;
        //    //sbXML.Append(GRAPH);
        //    sbXML.Append(CHART);
        //    int showv = 0;           //计算passv=0时的值个数，用来是否显示该图表
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        if (userPaperHistoryManager.GetPaperList_View(" and PaperID=" + dt.Rows[i]["PaperID"].ToString() + "", 1, 1).Rows.Count == 0)
        //        {
        //            maxv = 0;
        //        }
        //        else
        //        {
        //            maxv = int.Parse(userPaperHistoryManager.GetPaperList_View(" and PaperID=" + dt.Rows[i]["PaperID"].ToString() + "", 1, 1).Rows[0]["UserCount"].ToString());          //总人数
        //        }
        //        if (userPaperHistoryManager.GetPaperList_View(" and PaperID=" + dt.Rows[i]["PaperID"].ToString() + "", 1, 1).Rows.Count == 0)
        //        {
        //            passv = 0;
        //        }
        //        else
        //        {
        //            passv = int.Parse(userPaperHistoryManager.GetPaperList_View(" and PaperID=" + dt.Rows[i]["PaperID"].ToString() + "", 1, 1).Rows[0]["PassCount"].ToString());        //通过人数
        //        }
                
                
        //        if (passv == 0)
        //        {
        //            showv += 1;
        //        }
        //        passv = ReportUtils.GetBaiFenBi(passv.ToString(), maxv.ToString());
        //        sbXML.Append(string.Format(CHART_TR, dt.Rows[i]["PaperName"], passv));
        //    }

        //    sbXML.Append(CHART_END);


        //}

        return sbXML.ToString();
    }

    public int GetPaperPassCount(int paperid)
    {
        //string search = string.Format("PaperID={0}",paperid.ToString());
        //return userPaperHistoryManager.Count(search);
        return 0;
    }
}
